找传奇、传世资源到传世资源站!

糖果消消消游戏

8.5玩家评分(1人评分)
下载后可评
介绍 评论 失效链接反馈

消消乐游戏糖果消消消游戏 Python-第1张def getSwappingCandy(board, firstXY, secondXY):
    # 交换相邻糖果
    firstCandy = {'imageNum': board[firstXY['x']][firstXY['y']],
                'x': firstXY['x'],
                'y': firstXY['y']}
    secondCandy = {'imageNum': board[secondXY['x']][secondXY['y']],
                 'x': secondXY['x'],
                 'y': secondXY['y']}
    highlightedCandy = None
    # 左右相邻
    if firstCandy['x'] == secondCandy['x'] 1 and firstCandy['y'] == secondCandy['y']:
        firstCandy['direction'] = L
        secondCandy['direction'] = R
    elif firstCandy['x'] == secondCandy['x'] - 1 and firstCandy['y'] == secondCandy['y']:
        firstCandy['direction'] = R
        secondCandy['direction'] = L
    # 上下相邻
    elif firstCandy['y'] == secondCandy['y'] 1 and firstCandy['x'] == secondCandy['x']:
        firstCandy['direction'] = U
        secondCandy['direction'] = D
    elif firstCandy['y'] == secondCandy['y'] - 1 and firstCandy['x'] == secondCandy['x']:
        firstCandy['direction'] = D
        secondCandy['direction'] = U
        # 两个糖果不相邻就不能交换
    else:
        return None, None
    return firstCandy, secondCandy  # 此时两个糖果字典中的key值发生改变

评论

发表评论必须先登陆, 您可以 登陆 或者 注册新账号 !


在线咨询: 问题反馈
客服QQ:174666394

有问题请留言,看到后及时答复